package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.bean.OrderInfoBean;
import com.project.mapper.IOrderInfoMapper;
import com.project.service.IOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrderInfoServiceImpl implements IOrderInfoService {
    @Autowired
    private IOrderInfoMapper orderInfoMapper;
    @Override
    public List<OrderInfoBean> findByOrderId(Integer orderId) {
        QueryWrapper<OrderInfoBean> qw = new QueryWrapper<>();
        qw.eq("fk_orderId",orderId);
        return orderInfoMapper.selectList(qw);
    }

    @Override
    public void add(OrderInfoBean orderInfoBean) {
        orderInfoMapper.insert(orderInfoBean);
    }

    @Override
    public void addMore(List<OrderInfoBean> orderInfoBeanList) {
        for (OrderInfoBean orderInfo:orderInfoBeanList) {
            orderInfoMapper.insert(orderInfo);
        }
    }
}
